package persistent.prestige.web.demo.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import persistent.prestige.web.demo.service.DemoService;

/**
 * 测试入口
 * @author dingwei2
 *
 */
@Controller
@RequestMapping("/demo")
public class DemoControl {
	
	@Autowired
	private DemoService demoService;
	
	
	/**
	 * 测试事务问题，，在一个事务中，先查询List，然后更新一条数据，然后再次查询，然后再次更新
	 * 只有最后一条数据更新成功
	 * @param uid
	 * @return
	 */
	@RequestMapping("/testTransaction")
	@ResponseBody
	public Map testTransaction() {
		return demoService.saveQryAndSaveOrder();
	}
	
	
	/**
	 * 测试查询订单
	 * @param uid
	 * @return
	 */
	@RequestMapping("/testSelectOrder")
	@ResponseBody
	public Map testSelectOrder(String uid) {
		return demoService.testSelectOrder(uid);
	}
	
	/**
	 * 测试存储过程调用
	 * @return
	 */
	@RequestMapping("/testCallProcedure")
	@ResponseBody
	public Map testCallProcedure(int id) {
		return demoService.testCallProc(id);
	}
	
	@RequestMapping("/testERInsert")
	@ResponseBody
	public Map testERInsert() {
		return demoService.saveTestERInsert();
	}

}
